﻿using System;
using System.Collections.Generic;
using OpenFlashChartLib;
using OpenFlashChartLib.Charts;
using OpenFlashChartLib.Controls;
using Bar=OpenFlashChartLib.Charts.Bar;

namespace OpenFlashChartExample
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ofcTest.BuildChart();
        }

        protected void DrawChart(object sender, DrawChartEventArgs e)
        {
            Graph chart = new Graph();
            chart.Title = new Title("Bar Chart");

            var pie = new Pie();
            Random random = new Random();
            pie.Colours = new[] { "#d01f3c", "#356aa0", "#C79810", "#eeee0"};

            pie.Fillalpha = 0.4;
            pie.Text = "Test";
            pie.Animate = false;

            pie.Fontsize = 10;
            int max = int.MinValue;
            for (int i = 0; i < 12; i++)
            {
                int value = random.Next(i, i*2);
                if (value > max)
                    max = value;

                var val = new PieValue(value, i.ToString());
                pie.Values.Add(val);
            }
            chart.AddElement(pie);
            e.Graph = chart;
        }
    }
}
